package com.example.demo.common.utils;

import com.example.demo.information.entity.Bjxx;
import com.example.demo.information.entity.School;
import com.example.demo.information.entity.Student;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 描述：常用参数定义
 * @author littlecar
 * @date 2019/9/12 16:53
 */
public class Constant {

    public static final String Role_prefix = "Role";
    public static final String ADMIN = "超级管理员";
    public static final String XX_USER = "学校管理员";
    public static final String TEACHER = "教师";
    public static final String STUDENT = "学生";
    public static final Map<String, String> roleMap = new HashMap<>();
    static{
        roleMap.put("ADMIN", "超级管理员");
        roleMap.put("XX_USER", "学校管理员");
        roleMap.put("TEACHER", "教师");
        roleMap.put("STUDENT", "学生");
    }
    public static final Long ADMIN_ID = 1l;
    public static final Long XX_USER_ID = 4l;
    public static final Long TEACHER_ID = 6l;
    public static final Long STUDENT_ID = 8l;
    public static final Map<Long, String> roleIdMap = new HashMap<>();
    static{
        roleIdMap.put(1L, "ADMIN");
        roleIdMap.put(4L, "XX_USER");
        roleIdMap.put(6L, "TEACHER");
        roleIdMap.put(8L, "STUDENT");
    }
    public static final Map<String, Long> roleNameMap = new HashMap<>();
    static{
        roleNameMap.put("ADMIN", 1L);
        roleNameMap.put("XX_USER", 4L);
        roleNameMap.put("TEACHER", 6L);
        roleNameMap.put("STUDENT", 8L);
    }

    public static final Set<String> sexSet = new HashSet<>();
    static{
        sexSet.add("男");
        sexSet.add("女");
    }

    public static ThreadLocal<SimpleDateFormat> formatter = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        }
    };

    public static ThreadLocal<SimpleDateFormat> formatter2 = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS");
        }
    };

    public static ThreadLocal<SimpleDateFormat> formatterShort = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return new java.text.SimpleDateFormat("yyyyMMdd");
        }
    };
    /**
     * 用户查找范围
     */
    public static final String rangeUserAll = "all";//全部
    public static final String rangeUserAdmin = "admin";
    public static final String rangeUserManager = "manager";//默认是管理员,前面判断时null也全部
    public static final String rangeUserTeacher = "teacher";
    public static final String rangeUserStudent = "student";
    /**
     * 默认的一些照片参数
     */
    public static final String defaultPhotoPath = "static/imgesMob/sl.png";//默认的头像图片
    public static final String defaultPhotoObjectName = "default/defaultPhoto.jpg";//默认的头像图片
    public static final Integer defaultPhotoUrlTime = 10;//默认url有效时间

    public static final String defaultPhotoParamSpid = "1";
    public static final String defaultPhotoParamBkColor = "blue";
    public static final String defaultPhotoParamWidth = "295";
    public static final String defaultPhotoParamHeight = "413";
    public static final float defaultPhotoParamRatio = 0.3f;

    public static final String defaultBrowerMaxPhotoParamWidth = "350";
    public static final String defaultBrowerMaxPhotoParamHeight = "460";

    public static final String defaultPhotoNameParam = "@name@_@sfz@_@longDate@";//默认的照片导出参数
    public static final String defaultPhotoNameParamStr = "学生姓名_身份_当前时间";//默认的照片导出参数(String)
    public static final String defaultPhotoNameParamLine = "_";//默认的照片参数之间的连接符号

    /**
     * 照片查找范围
     */
    public static final String rangePhotoAll = "";//全部 ,前面判断时null也全部
    public static final String rangePhotoSet = "1";//已设置证件照
    public static final String rangePhotoNoSet = "2";//未设置证件照
    /**
     * 照片下载种类
     */
    public static final String typePhotoAll = "all";//全部，原图+证件照
    public static final String typePhotoOri = "original";//原图
    public static final String typePhotoPas = "passport";//证件照


    public static Map<String,String> photoParamSpidMap = new LinkedHashMap<>();
    static {
        photoParamSpidMap.put("1", "一寸@@25mmx35mm");
        photoParamSpidMap.put("2", "小一寸@@22mmx32mm");
        photoParamSpidMap.put("3", "大一寸@@33mmx48mm");
        photoParamSpidMap.put("4", "二寸@@35mmx49mm");
        photoParamSpidMap.put("5", "小二寸@@35mmx45mm");
        photoParamSpidMap.put("6", "大二寸@@35mmx53mm");
        /*photoParamSpidMap.put("7", "美国签证@@51mmx51mm");
        photoParamSpidMap.put("8", "日本签证@@45mmx45mm");
        photoParamSpidMap.put("9", "越南签证@@40mmx60mm");
        photoParamSpidMap.put("10", "身份证(无回执)@@26mmx32mm");
        photoParamSpidMap.put("11", "居住证@@26mmx32mm");
        photoParamSpidMap.put("13", "社保卡(350dpi,无回执,50100KB)@@358x411");
        photoParamSpidMap.put("14", "导游证@@285x385");
        photoParamSpidMap.put("15", "教师资格证@@25mmx35mm");
        photoParamSpidMap.put("16", "驾驶证、驾照(无回执,小一寸)@@22mmx32mm");
        photoParamSpidMap.put("17", "入学照@@25mmx35mm");
        photoParamSpidMap.put("18", "简历照片(一寸)@@25mmx35mm");*/
        photoParamSpidMap.put("19", "三寸@@54mmx84mm");
        photoParamSpidMap.put("20", "四寸@@76mmx102mm");
        photoParamSpidMap.put("21", "五寸@@89mmx127mm");
        /*photoParamSpidMap.put("22", "国考(二寸)@@35mmx45mm");
        photoParamSpidMap.put("23", "国考司法考试@@413x626");
        photoParamSpidMap.put("24", "医保证@@358x441");
        photoParamSpidMap.put("25", "健康证(一寸)@@25mmx35mm");
        photoParamSpidMap.put("26", "执法证@@358x441");
        photoParamSpidMap.put("27", "校园卡@@240x320");
        photoParamSpidMap.put("28", "入台证(小二寸)@@35mmx45mm");*/
        /*photoParamSpidMap.put("67", "学籍照片@@358x441");*///TODO 还有待补充，具体参考接口文档

    }

    public static Map<String,String> photoParamBkColorMap = new LinkedHashMap<>();
    static{
        photoParamBkColorMap.put("blue","蓝底");
        photoParamBkColorMap.put("red","红底");
        photoParamBkColorMap.put("white","白底");
        photoParamBkColorMap.put("blue_gradual","蓝色渐变");
        photoParamBkColorMap.put("red_gradual","红色渐变");
        photoParamBkColorMap.put("gray_gradual","灰色渐变");
    }

    public static final String initialPassword = "123456";
    public static final String initialEmail = "temp@temp.com";
    public static final String initialMobile = "13000000000";
    public static final String SUCCESS = "success";
    public static final String tempSaveFolder = "C:/Test/";
    public static final String tempTempFolder = "C:/Temp/";


    /**
     * 初始页码
     */
    public static final Integer defaultParamCurr = 1;
    public static final Integer defaultParamLimit = 10;

    /**
     * 索引树上的区分id类型  (school@id,bjxx@id,...)
     */
    public static final String TreeTypeSchool = "school";
    public static final String TreeTypeBjxx = "bjxx";
    public static final String TreeTypeStudent = "student";

    /**
     * PARAM_PZSM列表
     */
    public static final String PARAM_PZSM_PHOTO = "PhotoParam";//配置说明-照片参数 pzz1 spid pzz2 bkColor
    public static final String PARAM_PZSM_PHOTONAME = "PhotoNameParam";//配置说明-照片导出名 pzz1 参数组成的String

    /**
     * 照片导出名参数(学生参数)
     */
    public static Map<String,String> photoNameParamFromStuMap = new LinkedHashMap<>();
    static {
        photoNameParamFromStuMap.put("name","学生姓名");
        photoNameParamFromStuMap.put("sfz","身份证");
        photoNameParamFromStuMap.put("xjfh","学籍辅号");
        photoNameParamFromStuMap.put("sex","性别");
    }

    /**
     * 照片导出名参数(学生内含有的其他参数)
     */
    public static Map<String,String> photoNameParamFromStuMapOther = new LinkedHashMap<>();
    static {
        photoNameParamFromStuMapOther.put("school_name","学校名称");
        photoNameParamFromStuMapOther.put("bjxx_name","班级名称");
    }

    /**
     * 照片导出名参数(时间参数)
     */
    public static Map<String,String> photoNameParamFromDateToStrMap = new LinkedHashMap<>();
    static {
        photoNameParamFromDateToStrMap.put("longDate","当前长时间");
        photoNameParamFromDateToStrMap.put("shortDate","当前短时间");
        //photoNameParamFromDateToStrMap.put("date","当前时间");

    }

    /**
     * 时间参数调用map
     */
    public static Map<String,ThreadLocal<SimpleDateFormat>> photoNameParamFromDateMap = new LinkedHashMap<>();
    static {
        photoNameParamFromDateMap.put("longDate",formatter2);
        photoNameParamFromDateMap.put("shortDate",formatterShort);
        photoNameParamFromDateMap.put("date",formatter);

    }

    public static Student testStudent = new Student();//用来当作demoStudent
    static {
        testStudent.setName("张三");
        testStudent.setSfz("123456789123456789");
        testStudent.setXjfh("XJ123456");
        testStudent.setSex("男");
        Bjxx testBjxx = new Bjxx("初一1班");
        testStudent.setBjxx(testBjxx);
        School testSchool = new School("测试中学","测中");
        testStudent.setSchool(testSchool);
    }

    public static final Integer XX_1 = 11;//小学一年级
    public static final Integer XX_2 = 12;//小学二年级
    public static final Integer XX_3 = 13;//小学三年级
    public static final Integer XX_4 = 14;//小学四年级
    public static final Integer XX_5 = 15;//小学五年级
    public static final Integer XX_6 = 16;//小学六年级
    public static final Integer CZ_1 = 21;//初一
    public static final Integer CZ_2 = 22;//初二
    public static final Integer CZ_3 = 23;//初三
    public static final Integer GZ_1 = 31;//高一
    public static final Integer GZ_2 = 32;//高二
    public static final Integer GZ_3 = 33;//高三
    public static final Map<Integer, String> njmMap = new HashMap<>();
    static{
        njmMap.put(XX_1, "小学一年级");
        njmMap.put(XX_2, "小学二年级");
        njmMap.put(XX_3, "小学三年级");
        njmMap.put(XX_4, "小学四年级");
        njmMap.put(XX_5, "小学五年级");
        njmMap.put(XX_6, "小学六年级");
        njmMap.put(CZ_1, "初一");
        njmMap.put(CZ_2, "初二");
        njmMap.put(CZ_3, "初三");
        njmMap.put(GZ_1, "高一");
        njmMap.put(GZ_2, "高二");
        njmMap.put(GZ_3, "高三");
    }


}
